var DAO = require('./DAO')
var menuDAO = {
    getAllTrade:function(callback){
        DAO('select * from trade',function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getTradeId:function(tradeID,callback){
        DAO('select * from trade where tradeID = ?',tradeID,function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getFind:function(tradeName,callback){
        DAO('select * from trade where tradeName like ?',tradeName,function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getClassTrade:function(trade,callback){
        DAO('SELECT tradeName,price,images,className,dosing,advantage FROM trade join class on trade.classID = class.classID WHERE trade.classID = ?',trade.classID,function(err,results){
            if(err){
                callback(err,null)
            }
            else{
                callback(null,results)
            }
        })
    }
}
module.exports = menuDAO